
package com.cyq.dascma.result;

import java.sql.Timestamp;

public class ResultGenerator {
    private static final String DEFAULT_OK = "OK";

    public static Result genOkResult() {
        return new Result()
                .setCode(ResultCode.OK)
                .setMessage(DEFAULT_OK)
                .setCurrentTime(new Timestamp(System.currentTimeMillis()));
    }

    public static Result genOkResult(Object data) {
        return new Result()
                .setCode(ResultCode.OK)
                .setMessage(DEFAULT_OK)
                .setData(data)
                .setCurrentTime(new Timestamp(System.currentTimeMillis()));
    }

    public static Result genFailureResult(String message) {
        return new Result()
                .setCode(ResultCode.FAILURE)
                .setMessage(message)
                .setCurrentTime(new Timestamp(System.currentTimeMillis()));
    }
}
